package com.haihu.nx.supervision.redis.serializer.jdk;

import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;

import com.haihu.nx.supervision.redis.serializer.Serializer;

/**
 * Serializer for serialize and deserialize.
 * @author luqiantu
 * @version $Id: Serializer.java
 */
public class JdkSerializer implements Serializer {

    private JdkSerializationRedisSerializer jdkSerializationRedisSerializer = new JdkSerializationRedisSerializer();

    @Override
    public byte[] serialize(Object obj) throws SerializationException {
        
        return jdkSerializationRedisSerializer.serialize(obj);
    }
   
    @SuppressWarnings("unchecked")
    @Override
    public <T> T deserialize(byte[] data ) throws SerializationException {
         
        return (T) jdkSerializationRedisSerializer.deserialize(data);
    }

}
